package com.oracle.cmp.common;

import com.oracle.cmp.entity.Order;
import com.oracle.cmp.entity.OrderDetail;
import com.oracle.cmp.entity.Parts;
import com.oracle.cmp.service.OrderService;
import com.oracle.cmp.service.OrderServicelmpl;
import com.oracle.cmp.service.PartsService;
import com.oracle.cmp.service.PartsServiceImpl;
import org.apache.commons.httpclient.methods.multipart.Part;

import java.time.LocalDateTime;
import java.util.*;

public class Test {
    @org.junit.Test
   public void saveTest() {
//保存一个已经有的订单编号
       Order order=new Order();
       order.setOrdercode("DD2024012301");
       order.setOrderdate(new Date());
       order.setOrderflag("1");
       List<OrderDetail> details=new ArrayList();

       OrderDetail detail=new OrderDetail();
       detail.setPartsid(100);
       detail.setOrderpartscount(2);
       details.add(detail);
//连杆总成件(101)2件
       detail= new OrderDetail();
       detail.setPartsid(101)
       ;detail.setOrderpartscount(2);
       details.add(detail);
       OrderService orderService=new OrderServicelmpl();
       Result result=orderService.save(order,details,1);
       System.out.println(result);


   }
   @org.junit.Test
   public void deletetest(){
        OrderService orderService=new OrderServicelmpl();
        Result result=orderService.delete(20,"1");
       System.out.println(result);
   }
   @org.junit.Test
   public void update(){
       Order order=new Order();
       order.setOrdercode("DD2024012301");
       order.setOrderdate(new Date());
       order.setOrderflag("1");
       order.setOrderid(18);
       List<OrderDetail> details=new ArrayList();

       OrderDetail detail=new OrderDetail();
       detail.setPartsid(103);
       detail.setOrderpartscount(3);
       detail.setOrderid(18);
       details.add(detail);
//连杆总成件(101)2件
       detail= new OrderDetail();
       detail.setPartsid(102);
       detail.setOrderpartscount(3);
       details.add(detail);
       detail.setOrderid(18);
       OrderService orderService=new OrderServicelmpl();
       Result result=orderService.update(order,details,"1");
       System.out.println(result);
   }
//      100  in 3 44
//      101   in 2  94
//      102   out 3 52
    //  103   out 3 173
    @org.junit.Test
    public void query(){
//        Order order=new Order();
//        OrderService orderService=new OrderServicelmpl();
//        Map map=new HashMap();
//        Result result=orderService.queryForPage(map,1);
//        System.out.println(result);

        PartsService partsService=new PartsServiceImpl();
      List<Parts> parts = partsService.querajax("");
        System.out.println(parts);
    }
}
